#!/usr/bin/env node

const fs = require('fs');
//      src = process.argv[2],
//      lnk = process.argv[3];

let opt = {
  '4':createhardLink,
  '5':createSoftLink
};
function createSoftLink(){
  let opt = process.argv[2],
    src = process.argv[3],
    lnk = process.argv[4];
  if(opt === '-s'){
    try{
      fs.symlinkSync(src,lnk);
    }catch(e){
      console.error(e.message);
      process.exit(1);
    }
  }
  else{
    console.log('命令行参数不正确');
  }
}
function createhardLink(){
  let src = process.argv[2],
    lnk = process.argv[3];
  try{
    fs.linkSync(src,lnk);
  }catch(e){
    console.error(e.message);
    process.exit(2);
  }
}
try{
  opt[process.argv.length]();

}catch(e){
  console.error('命令行参数不正确');
  process.exit(3);
}

//fs.linkSync(src, lnk);




